import { PlusOutlined } from "@ant-design/icons";
import { ActionType, ProColumns, ProTable } from "@ant-design/pro-components";
import { Button, Form, Input, Modal } from "antd"
import { memo, useEffect, useRef, useState } from "react";
import { useRequest } from 'ahooks';
import { atlasList, projectCreate, projectDelete, projectList } from "../api/request";


interface PropsType {
    open: boolean;
    onClose: () => void;
}

const layout = {
    labelCol: { span: 4 },
    wrapperCol: { span: 18 },
};

const GraphRag = (props: PropsType) => {
    const { open, onClose } = props

    const actionRef = useRef<ActionType>();
    const [visibleCreate, setvisibleCreate] = useState(false);
    const [form] = Form.useForm();
    const { data, run: refreshTable } = useRequest(atlasList, {
        manual: true
    });

    const columns: ProColumns<Atlas>[] = [
        {
            title: '标题',
            dataIndex: 'title',
            search: false,
            width: 100
        },
        {
            title: '内容',
            dataIndex: 'content',
            search: true,
            ellipsis: true,
            width: 180
        },
        {
            title: '深度',
            dataIndex: 'depth',
            width: 180,
            hideInTable: true,
        },
        {
            title: '数量',
            search: true,
            dataIndex: 'num',
            hideInTable: true,
            width: 180
        }
    ]

    return <>
        <Modal open={open}
            footer={null}
            title="知识图谱"
            width={900}
            destroyOnClose={true}
            onClose={() => onClose()}
            onCancel={() => onClose()}>
            <ProTable<Atlas>
                columns={columns}
                actionRef={actionRef}
                cardBordered
                editable={{
                    type: 'multiple',
                }}
                request={async (params: Atlas) => {
                    return await atlasList(params) as any;
                }}
                rowKey="id"
                options={{
                    setting: {
                        listsHeight: 400,
                    },
                }}
                pagination={{
                    pageSize: 5
                }}
                dateFormatter="string"
            />
        </Modal>
    </>
}

export default memo(GraphRag)